package Image;

import com.wf.captcha.ArithmeticCaptcha;
import com.wf.captcha.ChineseCaptcha;
import com.wf.captcha.GifCaptcha;
import com.wf.captcha.SpecCaptcha;
import com.wf.captcha.base.Captcha;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.01.25.20.54
 */
public class Easy1 {
    public static void main(String[] args) throws FileNotFoundException {
        //此验证码类型，使用的是jdk1.8 的javascript Engine, 新版本中已经取消了此引擎，所以报错
        var c = new ArithmeticCaptcha();
        System.out.println(c.text());
        c.out(new FileOutputStream("c4.gif"));
        System.out.println(c.toBase64());
    }

    public static void gif(String[] args) throws FileNotFoundException {
        //gif
        var c = new GifCaptcha();
        c.setCharType(Captcha.TYPE_ONLY_NUMBER);
        System.out.println(c.text());
        c.out(new FileOutputStream("c3.gif"));
        System.out.println(c.toBase64());
    }

    public static void cn(String[] args) throws FileNotFoundException {
        //中文验证码    ChineseGifCaptcha中文的gif动画验证码效果
        var c = new ChineseCaptcha();
        c.out(new FileOutputStream("c2.png"));
    }

    public static void png(String[] args) throws Exception {
        //1 png格式验证码
        var c1 = new SpecCaptcha();
        c1 = new SpecCaptcha(100, 50, 4);
        System.out.println(c1.text());
        //base64字符串图像，
        System.out.println(c1.toBase64());
        c1.out(new FileOutputStream("c1.png"));
    }
}
